<?php
/**
 * @author wyl
 * @date 2015年7月28日16:09:29
 */
class CMenuProvider{
	public $_configs;
	public $position='nav';
	public $_menu;
	
	public function __construct(){
		$this->init();
	}
	
	public function init(){
		
	}
	
	public function menuData(){
		return $this->_menu;
	}
	
	public function buildMenuData(){
		$menu=$this->_configs;
		return $this->buildMenuItem($menu);
	}
	
	public function buildMenuItem($menu){
		$menuData = array();
		foreach ($menu as $menuKey => $menu){
			$menuData[$menuKey] = $menu;
		
			if (array_key_exists('url',$menu)){
				$menuData[$menuKey]['url'] = Yii::app()->request->baseUrl.$menu['url'];
			}else{
				$menuData[$menuKey]['active'] = false;
			}
			$menuData[$menuKey]['itemOptions'] = array();
			if (array_key_exists('items',$menu)){
				$menuData[$menuKey]['items'] = $this->buildMenuItem($menu['items']);
			}
		}
		return $menuData;
	}
}